home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 12930 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.0 KB

  1. Path: fas-news.harvard.edu!mito!robison
  2. From: robison@mito.harvard.edu (Keith Robison)
  3. Newsgroups: comp.lang.c++,comp.lang.java
  4. Subject: Re: Java: What's the Big Deal?
  5. Followup-To: comp.lang.c++,comp.lang.java
  6. Date: 22 Mar 1996 14:50:27 GMT
  7. Organization: Harvard University, Cambridge, Massachusetts
  8. Message-ID: <4iuenj$ng2@decaxp.HARVARD.EDU>
  9. References: <milodDoF9JF.K32@netcom.com> <1996Mar20.154600.12011@amc.com>
  10. NNTP-Posting-Host: mito.harvard.edu
  11. X-Newsreader: TIN [version 1.2 PL2]
  12.  
  13. Curtis Green (curtis@amc.com) wrote:
  14. : John DiCamillo (milod@netcom.com) wrote:
  15. : : pete@borland.com (Pete Becker) writes:
  16.  
  17. : : >>2) No header files => faster compilation
  18. : : 
  19. : : >Nonsense. Header files are simply text that gets included where you want it. If 
  20. : : >you write the same code without header files it will not magically compile 
  21. : : >faster.
  22. : : 
  23. : : It's not nonsense.  Cascaded #includes result in such a
  24. : : drastic inflation of the source text that it makes a measurable
  25. : : increase in compilation time.
  26. : If you surround your header file with #ifndef .. #endif you should be able
  27. : to eliminate your cascaded #include problem
  28. : foo.h
  29. : #ifndef FOO_H
  30. : #define FOO_H
  31. : ...
  32. : #endif
  33.  
  34. I think what the author was referring to was not multiply-including
  35. a particular header file (which is generally a compile-time error),
  36. but the fact that each header includes other headers which include
  37. other headers (etc).  This can indeed take a long time with a large
  38. header file collection, even if properly defended as above.
  39.  
  40. What is far more evil is that your namespace depends on this
  41. rat's nest of includes, and that the actual pattern of includes
  42. depends on the includes.  This is one feature I really like about
  43. Java -- you are required to explicitly set up your namespace, and
  44. therefore the namespace for a given compilation unit can be determined
  45. by the text in that source file; no identifiers sneaking in because
  46. they were included 10 levels back.  
  47.  
  48.  
  49. Keith Robison
  50. Harvard University
  51. Department of Molecular & Cellular Biology
  52. Department of Genetics 
  53.  
  54. robison@mito.harvard.edu 
  55.  
  56.